from typing import List
import bisect
class Solution:
    def nextGreatestLetter(self, letters: List[str], target: str) -> str:
      return letters[bisect.bisect(letters, target) % len(letters)]


if __name__ == '__main__':
  s = Solution()
  letters = ["c", "f", "j"]
  target = "a"
  print(s.nextGreatestLetter(letters, target))